<!DOCTYPE HTML>
<html>
<head>
	<#include "/adminPage/common.html"/>
	<link rel="stylesheet" type="text/css" href="${ctx}/lib/jsdifflib/diffview.css" />
	<style type="text/css">
		.name {
			padding: 10px;
			padding-left: 0px;
			font-size: 16px;
		}

		.title {
			margin-top: 5px;
			margin-bottom: 5px;
			height:30px;
			line-height:30px;
			cursor: pointer;
		}

		table.diff {
			width: 100%;
		}


		.long{
			width: 150px!important;
		}


		.layui-form-radio{
			width: 700px;
		}

		input[type='radio']{
			width: 1000px;
		}

	</style>
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">

	<#include "/adminPage/header.html"/>
	<#include "/adminPage/menu.html"/>

	<div class="layui-body">
		<!-- 内容主体区域 -->
		<fieldset class="layui-elem-field layui-field-title">
			<legend>SSO-OAuth2.0配置</legend>
		</fieldset>
		<form id="addForm" style="margin-top: 48px">

			<div class="layui-form-item">
				<label class="layui-form-label">code请求地址</label>
				<div class="layui-input-block">
					<input type="text" name="codeUrl" id="codeUrl" class="layui-input"  value="${codeUrl}">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">token获取地址</label>
				<div class="layui-input-block">
					<input type="text" name="tokenUrl" id="tokenUrl" class="layui-input"  value="${tokenUrl}">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">userinfo获取地址</label>
				<div class="layui-input-block">
					<input type="text" name="userinfoUrl" id="userinfoUrl" class="layui-input" value="${userinfoUrl}">
				</div>
			</div>


			<div class="layui-form-item">
				<label class="layui-form-label">用户属性键</label>
				<p style="font-size: 10px;">jsonpath表达式获取用户唯一信息，例如：$.a.b; 所得值需等于《用户名》</p>
				<div class="layui-input-block">
					<input type="text" name="jsonpath" id="jsonpath" class="layui-input" value="${jsonpath}">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">clientID</label>
				<div class="layui-input-block">
					<input type="text" name="clientID" id="clientID" class="layui-input" value="${clientID}">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">clientSecret</label>
				<div class="layui-input-block">
					<input type="text" name="clientSecret" id="clientSecret" class="layui-input" value="${clientSecret}">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">callback地址</label>
				<div class="layui-input-block">
					<input id="callbackUrl" name="callbackUrl" class="layui-input">
				</div>
			</div>


			<div class="layui-form-item center">
				<button type="button" class="layui-btn layui-btn-normal" onclick="save()">提交</button>
			</div>
		</form>

	</div>
</div>



<#include '/adminPage/script.html'/>
<#include '/adminPage/select_root.html'/>
<script src="${ctx}/lib/auto-line-number/auto-line-number.js" type="text/javascript"></script>
<script src="${ctx}/lib/jsdifflib/difflib.js" type="text/javascript"></script>
<script src="${ctx}/lib/jsdifflib/diffview.js" type="text/javascript"></script>
<script src="${ctx}/lib/base64/base64.js" type="text/javascript"></script>
<script type="application/javascript">

	const href = location.href.split('/');
	const host = href[0]+"//"+href[2];
	document.getElementById("callbackUrl").value=host+"/adminPage/sso/code";//host+"/adminPage/sso/code?code=xxxxxxx";

	async function save(){
		const form = document.getElementById('addForm');
		const formData = new FormData(form);
		const response = await fetch('/adminPage/sso/save', {
			method: 'POST',
			body: formData
		});
		const data = await response.json();
		if (data.success) {
			alert("成功")
		}else {
			alert(data.msg)
		}
	}
</script>
</body>


</html>